package com.edz.application.adapter;

import android.widget.ImageView;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.edz.application.R;
import com.edz.application.model.GameEntity;

import java.util.List;

/**
 * @author Created by EDZ on 2018/8/27.
 *         Describe
 */

public class GameAapter extends BaseQuickAdapter<GameEntity, BaseViewHolder> {

    public GameAapter(int layoutResId, List<GameEntity> dataList) {
        super(layoutResId, dataList);
    }

    @Override
    protected void convert(BaseViewHolder helper, GameEntity dataList) {
        String image = dataList.getGameMageUrl();
        if (!StringUtils.isEmpty(image)) {
            Glide.with(mContext).load(image).placeholder(R.mipmap.ic_launcher_round).into((ImageView) helper.getView(R.id.iv_image));
        }

        helper.setText(R.id.tv_name, dataList.getGameName());
        helper.setText(R.id.tv_publishman, dataList.getGamePublishUserName());

        String time = TimeUtils.millis2String(Long.parseLong(dataList.getGamePublishTime()));
        helper.setText(R.id.tv_publishtime, time);
    }
}
